from sqlalchemy import Column, Integer, String, DateTime, Text, Boolean
from database.database import Base
from datetime import datetime, timezone


class OTAFirmware(Base):
    """OTA固件模型 - 一条记录包含CM3和DSP两个程序"""
    __tablename__ = "ota_firmware"

    id = Column(Integer, primary_key=True, index=True)
    created_at = Column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
    updated_at = Column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc))
    
    # CM3程序信息
    cm3_version = Column(String(50), nullable=True)
    cm3_version_code = Column(Integer, nullable=True)
    cm3_file_name = Column(String(255), nullable=True)
    cm3_file_path = Column(String(500), nullable=True)
    cm3_file_size = Column(Integer, nullable=True)
    cm3_changelog = Column(Text, nullable=True)
    
    # DSP程序信息
    dsp_version = Column(String(50), nullable=True)
    dsp_version_code = Column(Integer, nullable=True)
    dsp_file_name = Column(String(255), nullable=True)
    dsp_file_path = Column(String(500), nullable=True)
    dsp_file_size = Column(Integer, nullable=True)
    dsp_changelog = Column(Text, nullable=True)
    
    # 是否激活
    is_active = Column(Boolean, default=True)
    
    # 备注信息
    remark = Column(Text, nullable=True) 